home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / zmdm / ymodem.doc < prev    next >
Text File  |  1993-06-26  |  56KB  |  1,353 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                      XMODEM/YMODEM PROTOCOL REFERENCE
  9.                  A compendium of documents describing the
  10.  
  11.                             XMODEM and YMODEM
  12.  
  13.                          File Transfer Protocols
  14.  
  15.  
  16.  
  17.  
  18.                    This document was formatted 9-11-86.
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                          Edited by Chuck Forsberg
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.                  Please distribute as widely as possible.
  42.  
  43.                        Questions to Chuck Forsberg
  44.  
  45.  
  46.  
  47.  
  48.  
  49.                            Omen Technology Inc
  50.                         17505-V Sauvie Island Road
  51.                           Portland Oregon 97231
  52.                            Voice: 503-621-3406
  53.             Modem (Telegodzilla): 503-621-3746 Speed 1200,300
  54.                           Compuserve: 70007,2304
  55.                     UUCP: ...!tektronix!reed!omen!caf
  56.  
  57.  
  58.                                  CONTENTS
  59.  
  60.  
  61.        1.  ROSETTA STONE....................................................  2
  62.  
  63.        2.  YET ANOTHER PROTOCOL?............................................  2
  64.            2.1  Some Messages from the Pioneer..............................  4
  65.  
  66.        3.  XMODEM PROTOCOL ENHANCEMENTS.....................................  5
  67.            3.1  Graceful Abort..............................................  6
  68.            3.2  CRC-16 Option...............................................  6
  69.            3.3  XMODEM-1k 1024 Byte Packet..................................  7
  70.  
  71.        4.  YMODEM Batch File Transmission...................................  7
  72.            4.1  KMD/IMP Exceptions to YMODEM................................ 13
  73.  
  74.        5.  YMODEM-g File Transmission....................................... 13
  75.  
  76.        6.  XMODEM PROTOCOL OVERVIEW......................................... 14
  77.            6.1  Definitions................................................. 14
  78.            6.2  Transmission Medium Level Protocol.......................... 15
  79.            6.3  File Level Protocol......................................... 16
  80.            6.4  Programming Tips............................................ 17
  81.  
  82.        7.  XMODEM/CRC Overview.............................................. 18
  83.            7.1  CRC Calculation............................................. 19
  84.            7.2  CRC File Level Protocol Changes............................. 19
  85.            7.3  Data Flow Examples with CRC Option.......................... 21
  86.  
  87.        8.  MORE INFORMATION................................................. 22
  88.  
  89.        9.  Document Revisions............................................... 23
  90.  
  91.       10.  YMODEM Programs.................................................. 23
  92.  
  93.  
  94.                              LIST OF FIGURES
  95.  
  96.  
  97.        Figure 1.  1024 byte Packets.........................................  7
  98.  
  99.        Figure 2.  Mixed 1024 and 128 byte Packets...........................  7
  100.  
  101.        Figure 3.  YMODEM Batch Transmission Session......................... 12
  102.  
  103.        Figure 4.  YMODEM Filename packet transmitted by sz.................. 12
  104.  
  105.        Figure 5.  YMODEM Header Information used by various programs........ 13
  106.  
  107.        Figure 6.  YMODEM-g Transmission Session............................. 14
  108.  
  109.        Figure 7.  XMODEM Message Block Level Protocol....................... 15
  110.  
  111.        Figure 8.  Data flow including Error Recovery........................ 17
  112.  
  113.        Figure 9.  Message Block Level Protocol, CRC mode.................... 18
  114.  
  115.       Figure 10.  Example of CRC Calculation written in C................... 19
  116.  
  117.       Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't........ 21
  118.  
  119.       Figure 12.  Receiver and Sender Both have CRC Option.................. 22
  120.  
  121.  
  122.       X/YMODEM Protocol Reference        09-11-86                        2
  123.  
  124.  
  125.  
  126.       1.  ROSETTA STONE
  127.  
  128.       Here are some definitions which reflect the current vernacular
  129.       in the computer media. The attempt here is identify the file
  130.       transfer protocol rather than specific programs.
  131.  
  132.       XMODEM refers to the original 1979 file transfer etiquette
  133.        introduced by Ward Christensen's 1979 MODEM2 program.  It's also
  134.        called the MODEM or MODEM2 protocol.  Some who are unaware of MODEM7's
  135.        unusual batch file mode call it MODEM7.  Other aliases include "CP/M
  136.        Users's Group" and "TERM II FTP 3".  This protocol is supported by
  137.        every serious communications program because of its universality,
  138.        simplicity, and reasonable performance.
  139.  
  140.       XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
  141.        Redundancy Check (CRC-16), giving modern error detection
  142.        protection.
  143.  
  144.       XMODEM-1k Refers to the XMODEM/CRC protocol with 1024 byte data blocks.
  145.  
  146.       YMODEM refers to the XMODEM/CRC (optional 1k blocks) protocol with the
  147.        batch transmission described below.
  148.  
  149.       ZMODEM uses familiar XMODEM/CRC and YMODEM technology in a
  150.        new protocol that provides reliability, throughput, file
  151.        management, and user amenities appropriate to contemporary
  152.        data communications.
  153.  
  154.  
  155.       2.  YET ANOTHER PROTOCOL?
  156.  
  157.       Since its development half a decade ago, the Ward Christensen modem
  158.       protocol has enabled a wide variety of computer systems to interchange
  159.       data.  There is hardly a communications program that doesn't at least
  160.       claim to support this protocol.
  161.  
  162.       Recent advances in computing, modems and networking have
  163.       revealed a number of weaknesses in the original protocol:
  164.  
  165.          + The short block length caused throughput to suffer when used with
  166.            timesharing systems, packet switched networks, satellite circuits,
  167.            and buffered (error correcting) modems.
  168.  
  169.          + The 8 bit arithmetic checksum and other aspects allowed line
  170.            impairments to interfere with dependable, accurate transfers.
  171.  
  172.          + Only one file could be sent per command.  The file name had to be
  173.            given twice, first to the sending program and then again to the
  174.            receiving program.
  175.  
  176.          + The transmitted file could accumulate as many as 127 extraneous
  177.            bytes.
  178.  
  179.  
  180.       X/YMODEM Protocol Reference        09-11-86                        3
  181.  
  182.  
  183.  
  184.          + The modification date of the file was lost.
  185.  
  186.       A number of other protocols have been developed over the
  187.       years, but none  have displaced XMODEM to date:
  188.  
  189.          + Lack of public domain documentation and example programs have kept
  190.            proprietary protocols such as MNP, Blast, and others
  191.            tightly bound to the fortunes of their suppliers.
  192.  
  193.          + Complexity discourages the widespread application of BISYNC, SDLC,
  194.            HDLC, X.25, and X.PC protocols.
  195.  
  196.          + Performance compromises and moderate complexity have limited the
  197.            popularity of the Kermit protocol, which was developed to allow file
  198.            transfers in environments hostile to XMODEM.
  199.  
  200.       The XMODEM protocol extensions and YMODEM Batch address these
  201.       weaknesses while maintaining XMODEM's simplicity.
  202.  
  203.       YMODEM is supported by the public domain programs YAM (CP/M),
  204.       YAM(CP/M-86), YAM(CCPM-86), IMP (CP/M), KMD (CP/M), rz/sz (Unix, Xenix,
  205.       VMS, Berkeley Unix, Venix, Xenix, Coherent, IDRIS, Regulus).  Commerical
  206.       implementations include MIRROR, and Professional-YAM.[1] Communications
  207.       programs supporting these extensions have been in use since 1981.
  208.  
  209.       The 1k packet length (XMODEM-1k) described below may be used in
  210.       conjunction with YMODEM Batch Protocol, or with single file transfers
  211.       identical to the XMODEM/CRC protocol except for minimal
  212.        changes to support 1k packets.
  213.  
  214.       Another extension is simply called the g option.  It provides maximum
  215.       throughput when used with end to end error correcting media,
  216.       such as X.PC and error correcting modems, including the emerging
  217.       9600 bps units by Electronic Vaults and others.
  218.  
  219.       To complete this tome, Ward Christensen's original protocol document and
  220.       John Byrns's CRC-16 document are included for reference.
  221.  
  222.       References to the MODEM or MODEM7 protocol have been changed
  223.       to XMODEM to accommodate the vernacular. In Australia, it is
  224.       properly called the Christensen Protocol.
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.       __________
  236.  
  237.        1. Available for IBM PC,XT,AT, Unix and Xenix
  238.  
  239.  
  240.       X/YMODEM Protocol Reference         09-11-86                      4
  241.  
  242.  
  243.  
  244.       2.1  Some Messages from the Pioneer
  245.  
  246.       #: 130940 S0/Communications 25-Apr-85  18:38:47
  247.       Sb: my protocol
  248.       Fm: Ward Christensen 76703,302 (EDITED)
  249.       To: all
  250.  
  251.       Be aware the article[2] DID quote me correctly in terms of the
  252.       phrases like "not robust", etc.
  253.  
  254.       It was a quick hack I threw together, very unplanned (like
  255.       everything I do), to satisfy a personal need to communicate with
  256.       "some other" people.
  257.  
  258.       ONLY the fact that it was done in 8/77, and that I put it in the public
  259.       domain immediately, made it become the standard that it is.
  260.  
  261.       I think its time for me to
  262.  
  263.       (1) document it; (people call me and say "my product is going
  264.           to include  it - what can I 'reference'", or "I'm writing a
  265.           paper on it, what do I put in the bibliography") and
  266.  
  267.       (2) propose an "incremental extension" to it, which might take
  268.           "exactly" the form of Chuck Forsberg's YAM protocol.  He
  269.            wrote YAM in C for CP/M and  put it in the public domain,
  270.            and wrote a batch protocol for Unix[3] called rb and sb
  271.            (receive batch, send batch), which was basically XMODEM with
  272.           (a) a record 0 containing filename date time and size
  273.           (b) a 1K block size option
  274.           (c) CRC-16.
  275.  
  276.       He did some clever programming to detect false ACK or EOT, but basically
  277.       left them the same.
  278.  
  279.       People who suggest I make SIGNIFICANT changes to the protocol,
  280.       such as "full duplex", "multiple outstanding blocks", "multiple
  281.       destinations", etc etc don't understand that the incredible
  282.       simplicity of the protocol is one of the reasons it survived to
  283.       this day in as many machines and programs as it may be found in!
  284.  
  285.       Consider the PC-NET group back in '77 or so - documenting to
  286.       beat the band
  287.       - THEY had a protocol, but it was "extremely complex", because
  288.         it tried to be "all things to all people" - i.e. send binary
  289.         files on a 7-bit system,  etc.  I was not that "benevolent". I
  290.         (emphasize > I < ) had an 8-bit UART,
  291.  
  292.  
  293.       __________
  294.  
  295.        2. Infoworld April 29 p. 16
  296.  
  297.        3. VAX/VMS versions of these programs are also available.
  298.  
  299.  
  300.       X/YMODEM Protocol Reference        09-11-86                        5
  301.  
  302.  
  303.  
  304.       so "my protocol was an 8-bit protocol", and I would just say "sorry" to
  305.       people who were held back by 7-bit limitations.  ...
  306.  
  307.       Block size: Chuck Forsberg created an extension of my protocol,
  308.       called YAM, which is also supported via his public domain
  309.       programs for UNIX called rb and sb - receive batch and send
  310.       batch.  They cleverly send a "block 0" which contains the
  311.       filename, date, time, and size. Unfortunately, its UNIX style,
  312.       and is abit weird[4] - octal numbers, etc. BUT, it is a nice way
  313.       to overcome the kludgy "echo the chars of the name" introduced
  314.       with MODEM7. Further, chuck uses CRC-16 and optional 1K blocks.
  315.       Thus the record 0, 1K, and CRC, make it a "pretty slick new
  316.       protocol" which is not significantly different from my own.
  317.  
  318.       Also, there is a catchy name - YMODEM. That means to some
  319.       that it is the  "next thing after XMODEM", and to others that it
  320.       is the Y(am)MODEM protocol.  I don't want to emphasize that too
  321.       much - out of fear that other mfgrs might think it is a
  322.       "competitive" protocol, rather than an "unaffiliated" protocol.
  323.       Chuck is currently selling a much-enhanced version of his
  324.       CP/M-80 C program YAM, calling it Professional Yam, and its
  325.       for the PC - I'm using it right now.  VERY slick!  32K capture buffer,
  326.       script, scrolling, previously captured text search, plus
  327.       built-in commands for just about everything - directory (sorted
  328.       every which way), XMODEM, YMODEM, KERMIT, and ASCII file
  329.       upload/download, etc.  You can program it to "behave" with most
  330.       any system - for example when trying a number for CIS it detects
  331.       the "busy" string back from the modem and substitutes a diff
  332.       phone # into the dialing string and branches back to try it.
  333.  
  334.  
  335.  
  336.       3.  XMODEM PROTOCOL ENHANCEMENTS
  337.  
  338.       This chapter discusses the protocol extensions to Ward Christensen's
  339.       1982 XMODEM protocol description document.
  340.  
  341.       The original document recommends the user be asked whether to continue
  342.       trying or abort after 10 retries.  Most programs no longer ask the
  343.       operator whether he wishes to keep retrying.  Virtually all correctable
  344.       errors are corrected within the first few retransmissions.  If
  345.       the line is so bad that ten attempts are insufficient, there is
  346.       a significant danger of undetected errors.  If the connection is
  347.       that bad, it's better to redial for a better connection, or
  348.       mail a floppy disk.
  349.  
  350.  
  351.  
  352.  
  353.  
  354.       __________
  355.  
  356.        4. The file length, time, and file mode are optional.The pathname and
  357.           file length may be sent alone if desired.
  358.  
  359.  
  360.       X/YMODEM Protocol Reference        09-11-86                        6
  361.  
  362.  
  363.  
  364.       3.1  Graceful Abort
  365.  
  366.       The YAM and Professional-YAM X/YMODEM routines recognize a
  367.       sequence of two consecutive CAN (Hex 18) characters without modem
  368.       errors (overrun, framing, etc.) as a transfer abort command.  This
  369.       sequence is recognized when YAM is waiting for the beginning of a
  370.       packet or for an acknowledge to one that has been sent.  The
  371.       check for two consecutive CAN characters virtually eliminates the
  372.       possibility of a line hit aborting the transfer.  YAM sends
  373.       eight CAN characters when it aborts an XMODEM, YMODEM, or ZMODEM
  374.       protocol file transfer.  Pro-YAM then sends eight backspaces to delete
  375.       the CAN characters from the remote's keyboard input buffer, in
  376.       case the remote had already aborted the transfer and was
  377.       awaiting a keyboarded command.
  378.  
  379.  
  380.       3.2  CRC-16 Option
  381.  
  382.       The XMODEM protocol uses an optional two character CRC-16
  383.       instead of the one character arithmetic checksum used by the original
  384.       protocol and by most commercial implementations.  CRC-16
  385.       guarantees detection of all single and double bit errors, all errors
  386.       with an odd number of error bits, all burst errors of length 16 or
  387.       less, 99.9969% of all 17-bit error bursts, and 99.9984 per cent
  388.       of all possible longer error bursts.  By contrast, a double bit
  389.       error, or a burst error of 9 bits or more can sneak past the
  390.       XMODEM protocol arithmetic checksum.
  391.  
  392.       The XMODEM/CRC protocol is similar to the XMODEM protocol,
  393.       except that the receiver specifies CRC-16 by sending C (Hex
  394.       43) instead of NAK when requesting the FIRST packet.  A two
  395.       byte CRC is sent in place of the one byte arithmetic checksum.
  396.  
  397.       YAM's c option to the r command enables CRC-16 in single file
  398.       reception, corresponding to the original implementation in the
  399.       MODEM7 series programs.  This remains the default because many
  400.       commercial communications programs and bulletin board systems still do
  401.       not support CRC-16, especially those written in Basic or Pascal.
  402.  
  403.       XMODEM protocol with CRC is accurate provided both sender and
  404.       receiver both report a successful transmission. The protocol is robust
  405.       in the presence of characters lost by buffer overloading on
  406.       timesharing systems.
  407.  
  408.       The single character ACK/NAK responses generated by the
  409.       receiving program adapt well to split speed modems, where the reverse
  410.       channel is limited to ten per cent or less of he main channel's speed.
  411.  
  412.       XMODEM and YMODEM are half duplex protocols which do not attempt to
  413.       transmit information and control signals in both directions at the same
  414.       time.  This avoids buffer overrun problems that have been reported by
  415.       users attempting to exploit full duplex asynchronous file transfer
  416.       protocols such as Blast.
  417.  
  418.       Professional-YAM adds several proprietary logic enhancements to XMODEM's
  419.  
  420.  
  421.       X/YMODEM Protocol Reference        09-11-86                        7
  422.  
  423.  
  424.  
  425.       error detection and recovery.  These compatible enhancements eliminate
  426.       most of the bad file transfers other programs make when using
  427.       the XMODEM protocol under less than ideal conditions.
  428.  
  429.  
  430.       3.3  XMODEM-1k 1024 Byte Packet
  431.  
  432.       The choice to use 1024 byte packets is expressed to the sending
  433.       program on its command line or selection menu.[1] 1024 byte packets
  434.       improve throughput in many applications, but some environments cannot
  435.       accept 1024 byte bursts, especially minicomuters running 19.2kb
  436.       ports.
  437.  
  438.       An STX (02) replaces the SOH (01) at the beginning of the transmitted
  439.       block to notify the receiver of the longer packet length.  The
  440.       transmitted packet contains 1024 bytes of data.  The receiver
  441.       should be able to accept any mixture of 128 and 1024 byte
  442.       packets.  The packet number is incremented by one for each
  443.       packet regardless of the packet length.
  444.  
  445.       The sender must not change between 128 and 1024 byte packet lengths if it
  446.       has not received a valid ACK for the current packet.  Failure to observe
  447.       this restriction allows certain transmission errors to pass undetected.
  448.  
  449.       If 1024 byte packets are being used, it is possible for a file to "grow"
  450.       up to the next multiple of 1024 bytes. This does not waste disk space if
  451.       the allocation granularity is 1k or greater.  With YMODEM batch
  452.       transmission, the optional file length transmitted in the file
  453.       name packet allows the receiver to discard the padding,
  454.       preserving the exact file length and contents.
  455.  
  456.       1024 byte packets may be used with batch file transmission or with single
  457.       file transmission.  CRC-16 should be used with the k option to preserve
  458.       data integrity over phone lines.  If a program wishes to enforce this
  459.       recommendation, it should cancel the transfer, then issue an informative
  460.       diagnostic message if the receiver requests checksum instead of CRC-16.
  461.       Under no circumstances may a sending program use CRC-16 unless the
  462.       receiver commands CRC-16.
  463.  
  464.  
  465.       4.  YMODEM Batch File Transmission
  466.  
  467.       The YMODEM Batch protocol is an extension to the XMODEM/CRC protocol that
  468.       allows 0 or more files to be transmitted with a single command.  (Zero
  469.       files may be sent if none of the requested files is accessible.) The
  470.       design approach of the YMODEM Batch protocol is to use the
  471.       normal routines for sending and receiving XMODEM packets in a
  472.       layered fashion similar to
  473.  
  474.  
  475.  
  476.       __________
  477.  
  478.        1. See "KMD/IMP Exceptions to YMODEM" below.
  479.  
  480.  
  481.       X/YMODEM Protocol Reference         09-11-86                      8
  482.  
  483.  
  484.  
  485.          Figure 1.  1024 byte Packets
  486.  
  487.           SENDER                                  RECEIVER
  488.                                                   "s -k foo.bar"
  489.           "foo.bar open x.x minutes"
  490.                                                   C
  491.           STX 01 FE Data[1024] CRC CRC
  492.                                                   ACK
  493.           STX 02 FD Data[1024] CRC CRC
  494.                                                   ACK
  495.           STX 03 FC Data[1000] CPMEOF[24] CRC CRC
  496.                                                   ACK
  497.           EOT
  498.                                                   ACK
  499.  
  500.          Figure 2.  Mixed 1024 and 128 byte Packets
  501.  
  502.           SENDER                                  RECEIVER
  503.                                                   "s -k foo.bar"
  504.           "foo.bar open x.x minutes"
  505.                                                   C
  506.           STX 01 FE Data[1024] CRC CRC
  507.                                                   ACK
  508.           STX 02 FD Data[1024] CRC CRC
  509.                                                   ACK
  510.           SOH 03 FC Data[128] CRC CRC
  511.                                                   ACK
  512.           SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  513.                                                   ACK
  514.           EOT
  515.                                                   ACK
  516.  
  517.       packet switching methods.
  518.  
  519.       Why was it necessary to design a new batch protocol when one already
  520.       existed in MODEM7?[1] The batch file mode used by MODEM7 is unsuitable
  521.       because it does not permit full pathnames, file length, file date, or
  522.       other attribute information to be transmitted. Such a restrictive design,
  523.       hastily implemented with only CP/M in mind, would not have permitted
  524.       extensions to current areas of personal computing such as Unix, DOS, and
  525.       object oriented systems.  In addition, the MODEM7 batch file mode is
  526.       somewhat susceptible to transmission impairments.
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.       __________
  535.  
  536.        1. The MODEM7 batch protocol transmitted CP/M FCB bytes f1...f8 and
  537.           t1...t3 one character at a time.  The receiver echoed these bytes as
  538.           received, one at a time.
  539.  
  540.  
  541.       X/YMODEM Protocol Reference        09-11-86                        9
  542.  
  543.  
  544.  
  545.       As in the case of single a file transfer, the receiver initiates batch
  546.       file transmission by sending a "C" character (for CRC-16).
  547.  
  548.       The sender opens the first file and sends packet number 0 with the
  549.       following information.[2]
  550.  
  551.       Only the pathname (file name) part is required for batch transfers.
  552.  
  553.       To maintain upwards compatibility, all unused bytes in packet 0 must be
  554.       set to null.
  555.  
  556.       Pathname The pathname (conventionally, the file name) is sent as a null
  557.            terminated ASCII string.  This is the filename format used by the
  558.            handle oriented MSDOS(TM) functions and C library fopen functions.
  559.            An assembly language example follows:
  560.                       DB      'foo.bar',0
  561.            No spaces are included in the pathname.  Normally only the file name
  562.            stem (no directory prefix) is transmitted unless the sender has
  563.            selected YAM's f option to send the full pathname.  The source drive
  564.            (A:, B:, etc.) is never sent.
  565.  
  566.            Filename Considerations:
  567.  
  568.         + File names should be translated to lower case unless the sending
  569.          system supports upper/lower case file names. This is a
  570.          convenience for users of systems (such as Unix) which store
  571.          filenames in upper and lower case.
  572.  
  573.        + The receiver should accommodate file names in lower and upper
  574.          case.
  575.  
  576.        + When transmitting files between different operating systems,
  577.          file names must be acceptable to both the sender and receiving
  578.          operating systems.
  579.  
  580.            If directories are included, they are delimited by /; i.e.,
  581.            "subdir/foo" is acceptable, "subdir\foo" is not.
  582.  
  583.       Length The file length and each of the succeeding fields are optional.[3]
  584.            The length field is stored in the packet as a decimal
  585.            string counting the number of data bytes in the file.  The
  586.            file length does not include any CPMEOF (^Z) or other
  587.            garbage characters used to pad the last packet.
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.       __________
  595.  
  596.        2. Only the data part of the packet is described here.
  597.  
  598.        3. Fields may not be skipped.
  599.  
  600.  
  601.       X/YMODEM Protocol Reference  09-11-86                             10
  602.  
  603.  
  604.  
  605.            If the file being transmitted is growing during transmission, the
  606.            length field should be set to at least the final expected file
  607.            length, or not sent.
  608.  
  609.            The receiver stores the specified number of characters, discarding
  610.            any padding added by the sender to fill up the last packet.
  611.  
  612.       Modification Date The mod date is optional, and the filename and length
  613.            may be sent without requiring the mod date to be sent.
  614.  
  615.            Iff the modification date is sent, a single space separates the
  616.            modification date from the file length.
  617.  
  618.            The mod date is sent as an octal number giving the time the contents
  619.            of the file were last changed, measured in seconds from Jan 1 1970
  620.            Universal Coordinated Time (GMT). A date of 0 implies the
  621.            modification date is unknown and should be left as the date the file
  622.            is received.
  623.  
  624.            This standard format was chosen to eliminate ambiguities
  625.            arising from transfers between different time zones.
  626.  
  627.            Two Microsoft blunders complicate the use of modification dates in
  628.            file transfers with MSDOS(TM) systems.  The first is the lack of
  629.            timezone standardization in MS-DOS.  A file's creation time can not
  630.            be known unless the timezone of the system that wrote the file[4] is
  631.            known.  Unix solved this problem (for planet Earth, anyway) by
  632.            stamping files with Universal Time (GMT). Microsoft would have to
  633.            include the timezone of origin in the directory entries, but does
  634.            not.  Professional-YAM gets around this problem by using the z
  635.            parameter which is set to the number of minutes local time lags GMT.
  636.            For files known to originate from a different timezone, the -zT
  637.            option may be used to specify T as the timezone for an individual
  638.            file transfer.
  639.  
  640.            The second problem is the lack of a separate file creation date in
  641.            DOS.  Since some backup schemes used with DOS rely on the file
  642.            creation date to select files to be copied to the archive, back-
  643.            dating the file modification date could interfere with the safety of
  644.            the transferred files.  For this reason, Pro-YAM does not modify the
  645.            date of received files with the header information unless the d
  646.            numeric parameter is non zero.
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.       __________
  657.  
  658.        4. Not necessarily that of the transmitting system!
  659.  
  660.  
  661.       X/YMODEM Protocol Reference        09-11-86                       11
  662.  
  663.  
  664.  
  665.       Mode Iff the file mode is sent, a single space separates the file mode
  666.            from the modification date.  The file mode is stored as an octal
  667.            string.  Unless the file originated from a Unix system, the
  668.            file mode is set to 0.  rb(1) checks the file mode for the
  669.            0x8000 bit which indicates a Unix type regular file.  Files
  670.            with the 0x8000 bit set are assumed to have been sent from
  671.            another Unix (or similar) system which uses the same file
  672.            conventions.  Such files are not translated in any way.
  673.  
  674.  
  675.       Serial Number Iff the serial number is sent, a single space separates the
  676.            serial number from the file mode. The serial number of the
  677.            transmitting program is stored as an octal string.
  678.            Programs which do not have a serial number should omit this
  679.            field, or set it to 0.  The receiver's use of this field is
  680.            optional.
  681.  
  682.  
  683.       Other Fields YMODEM was designed to allow additional header fields to be
  684.            added as above without creating compatibility problems with older
  685.            YMODEM programs.  Please contact Omen Technology if other fields are
  686.            needed for special application requirements.
  687.  
  688.       The rest of the packet is set to nulls.  This is essential to preserve
  689.       upward compatibility.[5]
  690.  
  691.       If the filename packet is received with a CRC or other error, a
  692.       restrnsmission is requested.  After the filename packet has been
  693.       received, it is ACK'ed if the write open is successful.  If the
  694.       file cannot be opened for writing, the receiver cancels the
  695.       transfer with CAN characters as described above.
  696.  
  697.       The receiver then initiates transfer of the file contents
  698.       according to the standard XMODEM/CRC protocol.
  699.  
  700.       After the file contents have been transmitted, the receiver
  701.       again asks for the next pathname.  Transmission of a null
  702.       pathname terminates batch file transmission.  Note that
  703.       transmission of no files is not necessarily an error. This is
  704.       possible if none of the files requested of the sender could be
  705.       opened for reading.
  706.  
  707.       In batch transmission, the receiver automatically requests CRC-16.
  708.  
  709.       The Unix programs sz(1) and rz(1) included in the source code file
  710.  
  711.  
  712.  
  713.  
  714.       __________
  715.  
  716.        5. If, perchance, this information extends beyond 128 bytes (possible
  717.           with Unix 4.2 BSD extended file names), the packet should be
  718.           sent as a 1k packet as described above.
  719.  
  720.  
  721.       X/YMODEM Protocol Reference        09-11-86                       12
  722.  
  723.  
  724.  
  725.       RZSZ[12].SHQ (rzsz1.sh, rzsz2.sh) should answer other questions about
  726.       YMODEM batch protocol.
  727.  
  728.          Figure 3.  YMODEM Batch Transmission Session
  729.  
  730.           SENDER                                  RECEIVER
  731.                                                   "sb foo.*<CR>"
  732.           "sending in batch mode etc."
  733.                                                   C (command:rb)
  734.           SOH 00 FF foo.c NUL[123] CRC CRC
  735.                                                   ACK
  736.                                                   C
  737.           SOH 01 FE Data[128] CRC CRC
  738.                                                   ACK
  739.           STX 02 FD Data[1024] CRC CRC
  740.                                                   ACK
  741.           SOH 03 FC Data[128] CRC CRC
  742.                                                   ACK
  743.           SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  744.                                                   ACK
  745.           EOT
  746.                                                   NAK
  747.           EOT
  748.                                                   ACK
  749.                                                   C
  750.           SOH 00 FF NUL[128] CRC CRC
  751.                                                   ACK
  752.  
  753.              Figure 4.  YMODEM Filename packet transmitted by sz
  754.  
  755.              -rw-r--r--  6347 Jun 17 1984 20:34 bbcsched.txt
  756.  
  757.              00 0100FF62 62637363 6865642E 74787400     |...bbcsched.txt.|
  758.              10 36333437 20333331 34373432 35313320     |6347 3314742513 |
  759.              20 31303036 34340000 00000000 00000000     |100644..........|
  760.              30 00000000 00000000 00000000 00000000
  761.              80 000000CA 56
  762.  
  763.  
  764.       X/YMODEM Protocol Reference        09-11-86                       13
  765.  
  766.  
  767.  
  768.             Figure 5.    YMODEM Header Information used by various programs
  769.  
  770.       _____________________________________________________________________
  771.       | Program   | Batch | Length | Date | Mode | S/N | 1k-Blk | g-Option |
  772.       |___________|_______|________|______|______|_____|________|__________|
  773.       |Unix rz/sz | yes   | yes    | yes  | yes  | no  | yes    | sb only  |
  774.       |___________|_______|________|______|______|_____|________|__________|
  775.       |VMS rb/sb  | yes   | yes    | no   | no   | no  | yes    | no       |
  776.       |___________|_______|________|______|______|_____|________|__________|
  777.       |Pro-YAM    | yes   | yes    | yes  | no   | yes | yes    | yes      |
  778.       |___________|_______|________|______|______|_____|________|__________|
  779.       |CP/M YAM   | yes   | no     | no   | no   | no  | yes    | no       |
  780.       |___________|_______|________|______|______|_____|________|__________|
  781.       |KMD/IMP    | yes   | ?      | no   | no   | no  | yes    | no       |
  782.       |___________|_______|________|______|______|_____|________|__________|
  783.  
  784.       4.1  KMD/IMP Exceptions to YMODEM
  785.  
  786.       KMD and IMP character sequence emitted by the receiver (CK) to
  787.       automatically trigger the use of 1024 byte packets as an alternative to
  788.       specifying this option on this command line.  Although this two character
  789.       sequence works well on single process micros in direct communication,
  790.       timesharing systems and packet switched networks can separate the
  791.       successive characters by several seconds, rendering this method
  792.       unreliable.
  793.  
  794.       Sending programs may detect the CK sequence if the operating enviornment
  795.       does not preclude reliable implementation.
  796.  
  797.       Receiving programs should retain the option of sending the
  798.       standard YMODEM C (not CK) trigger with the standard 10 second
  799.       timeout to insure compatibility with newer forms of
  800.       telecommunications technology.
  801.  
  802.  
  803.  
  804.       5.  YMODEM-g File Transmission
  805.  
  806.       Developing technology is providing phone line data transmission at ever
  807.       higher speeds using very specialized techniques.  These high
  808.       speed modems, as well as session protocols such as X.PC, provide
  809.       high speed, error free communications at the expense of
  810.       considerably increased delay time.
  811.  
  812.       This delay time is moderate compared to human interactions, but it
  813.       cripples the throughput of most error correcting protocols.
  814.  
  815.       The g option to YMODEM has proven effective under these circumstances.
  816.       The g option is driven by the receiver, which initiates the
  817.       batch transfer by transmitting a G instead of C.  When the
  818.       sender recognizes the G, it bypasses the usual wait for an ACK
  819.       to each transmitted packet, sending succeeding packets at full
  820.       speed, subject to XOFF/XON or other flow control exerted by the medium.
  821.  
  822.  
  823.       X/YMODEM Protocol Reference        09-11-86                       14
  824.  
  825.  
  826.  
  827.       The sender expects an inital G to initiate the transmission of a
  828.       particular file, and also expects an ACK on the EOT sent at the end of
  829.       each file.  This synchronization allows the receiver time to open and
  830.       close files as necessary.
  831.  
  832.       If an error is detected in a YMODEM-g transfer, the receiver aborts the
  833.       transfer with the multiple CAN abort sequence. The ZMODEM protocol should
  834.       be used in applications that require both streaming throughput and error
  835.       recovery.
  836.  
  837.              Figure 6.  YMODEM-g Transmission Session
  838.  
  839.              SENDER                                      RECEIVER
  840.                                                  "sb foo.*<CR>"
  841.              "sending   in batch mode etc..."
  842.                                                  G (command:rb -g)
  843.              SOH 00 FF foo.c NUL[123]   CRC CRC
  844.                                                  G
  845.              SOH 01 FE Data[128] CRC CRC
  846.              STX 02 FD Data[1024] CRC   CRC
  847.              SOH 03 FC Data[128] CRC CRC
  848.              SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  849.              EOT
  850.                                                  ACK
  851.                                                  G
  852.              SOH 00 FF NUL[128] CRC CRC
  853.  
  854.  
  855.       6.  XMODEM PROTOCOL OVERVIEW
  856.  
  857.       8/9/82 by Ward Christensen.
  858.  
  859.       I will maintain a master copy of this. Please pass on changes or
  860.       suggestions via CBBS/Chicago at (312) 545-8086, CBBS/CPMUG (312) 849-1132
  861.       or by voice at (312) 849-6279.
  862.  
  863.       6.1  Definitions
  864.  
  865.         <soh>   01H
  866.         <eot>   04H
  867.         <ack>   06H
  868.         <nak>   15H
  869.         <can>   18H
  870.         <C>     43H
  871.  
  872.  
  873.       X/YMODEM Protocol Reference        09-11-86                       15
  874.  
  875.  
  876.  
  877.       6.2  Transmission Medium Level Protocol
  878.  
  879.       Asynchronous, 8 data bits, no parity, one stop bit.
  880.  
  881.       The protocol imposes no restrictions on the contents of the data being
  882.       transmitted.  No control characters are looked for in the 128-byte data
  883.       messages.  Absolutely any kind of data may be sent - binary, ASCII, etc.
  884.       The protocol has not formally been adopted to a 7-bit environment for the
  885.       transmission of ASCII-only (or unpacked-hex) data , although it could be
  886.       simply by having both ends agree to AND the protocol-dependent data with
  887.       7F hex before validating it.  I specifically am referring to the
  888.       checksum, and the block numbers and their ones- complement.
  889.  
  890.       Those wishing to maintain compatibility of the CP/M file structure, i.e.
  891.       to allow modemming ASCII files to or from CP/M systems should follow this
  892.       data format:
  893.  
  894.          + ASCII tabs used (09H); tabs set every 8.
  895.  
  896.          + Lines terminated by CR/LF (0DH 0AH)
  897.  
  898.          + End-of-file indicated by ^Z, 1AH. (one or more)
  899.  
  900.          + Data is variable length, i.e. should be considered a continuous
  901.            stream of data bytes, broken into 128-byte chunks purely for the
  902.            purpose of transmission.
  903.  
  904.          + A CP/M "peculiarity": If the data ends exactly on a 128-byte
  905.            boundary, i.e. CR in 127, and LF in 128, a subsequent sector
  906.            containing the ^Z EOF character(s) is optional, but is preferred.
  907.            Some utilities or user programs still do not handle EOF without ^Zs.
  908.  
  909.          + The last block sent is no different from others, i.e.  there is no
  910.            "short block".
  911.               Figure 7.  XMODEM Message Block Level Protocol
  912.  
  913.       Each block of the transfer looks like:
  914.             <SOH><blk #><255-blk #><--128 data bytes--><cksum>
  915.       in which:
  916.       <SOH>           = 01 hex
  917.       <blk #>         = binary number, starts at 01 increments by 1, and
  918.                 wraps 0FFH to 00H (not to 01)
  919.       <255-blk #>   =   blk # after going thru 8080 "CMA" instr, i.e.
  920.                 each bit complemented in the 8-bit block number.
  921.                 Formally, this is the "ones complement".
  922.       <cksum>       = the sum of the data bytes only.  Toss any carry.
  923.  
  924.  
  925.       X/YMODEM Protocol Reference        09-11-86                       16
  926.  
  927.  
  928.  
  929.       6.3  File Level Protocol
  930.  
  931.       6.3.1  Common_to_Both_Sender_and_Receiver
  932.       All errors are retried 10 times.  For versions running with an operator
  933.       (i.e. NOT with XMODEM), a message is typed after 10 errors asking the
  934.       operator whether to "retry or quit".
  935.  
  936.       Some versions of the protocol use <can>, ASCII ^X, to cancel
  937.       transmission. This was never adopted as a standard, as having a
  938.       single "abort" character makes the transmission susceptible to
  939.       false termination due to an <ack> <nak> or <soh> being corrupted
  940.       into a <can> and aborting transmission.
  941.  
  942.       The protocol may be considered "receiver driven", that is, the
  943.       sender need not automatically re-transmit, although it does in
  944.       the current implementations.
  945.  
  946.  
  947.       6.3.2  Receive_Program_Considerations
  948.       The receiver has a 10-second timeout.  It sends a <nak> every time it
  949.       times out.  The receiver's first timeout, which sends a <nak>,
  950.       signals the transmitter to start.  Optionally, the receiver
  951.       could send a <nak> immediately, in case the sender was ready.
  952.       This would save the initial 10 second timeout.  However, the
  953.       receiver MUST continue to timeout every 10 seconds in case the
  954.       sender wasn't ready.
  955.  
  956.       Once into a receiving a block, the receiver goes into a
  957.       one-second timeout for each character and the checksum.  If the
  958.       receiver wishes to <nak> a block for any reason (invalid header,
  959.       timeout receiving data), it must wait for the line to clear.
  960.       See "programming tips" for ideas.
  961.  
  962.       Synchronizing: If a valid block number is received, it will be: 1) the
  963.       expected one, in which case everything is fine; or 2) a repeat of the
  964.       previously received block.  This should be considered OK, and only
  965.       indicates that the receivers <ack> got glitched, and the sender re-
  966.       transmitted; 3) any other block number indicates a fatal loss of
  967.       synchronization, such as the rare case of the sender getting a
  968.       line-glitch that looked like an <ack>.  Abort the transmission,
  969.       sending a <can>
  970.  
  971.  
  972.       6.3.3  Sending_program_considerations
  973.       While waiting for transmission to begin, the sender has only a
  974.       single very long timeout, say one minute.  In the current
  975.       protocol, the sender has a 10 second timeout before retrying.  I
  976.       suggest NOT doing this, and letting the protocol be completely
  977.       receiver-driven.  This will be compatible with existing programs.
  978.  
  979.       When the sender has no more data, it sends an <eot>, and awaits an <ack>,
  980.       resending the <eot> if it doesn't get one.  Again, the protocol could be
  981.       receiver-driven, with the sender only having the high-level 1-minute
  982.       timeout to abort.
  983.  
  984.  
  985.       X/YMODEM Protocol Reference        09-11-86                       17
  986.  
  987.  
  988.  
  989.       Here is a sample of the data flow, sending a 3-block message.
  990.       It includes the two most common line hits - a garbaged block,
  991.       and an <ack> reply getting garbaged.  <xx> represents the checksum byte.
  992.  
  993.              Figure 8.  Data flow including Error Recovery
  994.  
  995.       SENDER                            RECEIVER
  996.                               times out after 10 seconds,
  997.                               <---              <nak>
  998.       <soh> 01 FE -data- <xx>         --->
  999.                               <---              <ack>
  1000.       <soh> 02 FD -data- xx           --->       (data gets line hit)
  1001.                               <---              <nak>
  1002.       <soh> 02 FD -data- xx           --->
  1003.                               <---              <ack>
  1004.       <soh> 03 FC -data- xx           --->
  1005.       (ack gets garbaged)             <---              <ack>
  1006.       <soh> 03 FC -data- xx           --->              <ack>
  1007.       <eot>                           --->
  1008.                               <---       <anything except ack>
  1009.       <eot>                           --->
  1010.                               <---              <ack>
  1011.       (finished)
  1012.  
  1013.       6.4  Programming Tips
  1014.  
  1015.          + The character-receive subroutine should be called with a parameter
  1016.            specifying the number of seconds to wait. The receiver should first
  1017.            call it with a time of 10, then <nak> and try again, 10 times.
  1018.  
  1019.            After receiving the <soh>, the receiver should call the character
  1020.            receive subroutine with a 1-second timeout, for the remainder of the
  1021.            message and the <cksum>.  Since they are sent as a
  1022.            continuous stream, timing out of this implies a serious
  1023.            like glitch that caused, say, 127 characters to be seen
  1024.            instead of 128.
  1025.  
  1026.          + When the receiver wishes to <nak>, it should call a "PURGE"
  1027.            subroutine, to wait for the line to clear.  Recall the sender tosses
  1028.            any characters in its UART buffer immediately upon
  1029.            completing sending a block, to ensure no glitches were mis-
  1030.            interpreted.
  1031.  
  1032.            The most common technique is for "PURGE" to call the character
  1033.            receive subroutine, specifying a 1-second timeout,[1] and looping
  1034.            back to PURGE until a timeout occurs.  The <nak> is then sent,
  1035.            ensuring the other end will see it.
  1036.  
  1037.  
  1038.  
  1039.  
  1040.       __________
  1041.  
  1042.        1. These times should be adjusted for use with timesharing systems.
  1043.  
  1044.  
  1045.       X/YMODEM Protocol Reference        09-11-86                       18
  1046.  
  1047.  
  1048.  
  1049.          + You may wish to add code recommended by John Mahr to your character
  1050.            receive routine - to set an error flag if the UART shows framing
  1051.            error, or overrun.  This will help catch a few more glitches - the
  1052.            most common of which is a hit in the high bits of the byte in two
  1053.            consecutive bytes.  The <cksum> comes out OK since counting
  1054.            in 1-byte produces the same result of adding 80H + 80H as
  1055.            with adding 00H + 00H.
  1056.  
  1057.  
  1058.  
  1059.       7.  XMODEM/CRC Overview
  1060.  
  1061.       1/13/85 by John Byrns -- CRC option.
  1062.  
  1063.       Please pass on any reports of errors in this document or suggestions for
  1064.       improvement to me via Ward's/CBBS at (312) 849-1132, or by voice at (312)
  1065.       885-1105.
  1066.  
  1067.       The CRC used in the Modem Protocol is an alternate form of block check
  1068.       which provides more robust error detection than the original checksum.
  1069.       Andrew S. Tanenbaum says in his book, Computer Networks, that the CRC-
  1070.       CCITT used by the Modem Protocol will detect all single and double bit
  1071.       errors, all errors with an odd number of bits, all burst errors of length
  1072.       16 or less, 99.997% of 17-bit error bursts, and 99.998% of 18-bit and
  1073.       longer bursts.
  1074.  
  1075.       The changes to the Modem Protocol to replace the checksum with
  1076.       the CRC are straight forward. If that were all that we did we
  1077.       would not be able to communicate between a program using the old
  1078.       checksum protocol and one using the new CRC protocol. An initial
  1079.       handshake was added to solve this problem. The handshake allows
  1080.       a receiving program with CRC capability to determine whether the
  1081.       sending program supports the CRC option, and to switch it to CRC
  1082.       mode if it does. This handshake is designed so that it will work
  1083.       properly with programs which implement only the original
  1084.       protocol. A description of this handshake is presented in section 10.
  1085.  
  1086.            Figure 9.  Message Block Level Protocol, CRC mode
  1087.  
  1088.       Each block of the transfer in CRC mode looks like:
  1089.            <SOH><blk #><255-blk #><--128 data   bytes--><CRC hi><CRC lo>
  1090.       in which:
  1091.       <SOH>          = 01 hex
  1092.       <blk #>        = binary number, starts at 01 increments by 1, and
  1093.                wraps 0FFH to 00H (not to 01)
  1094.       <255-blk #>  = ones complement of blk #.
  1095.       <CRC hi>     = byte containing the 8 hi   order coefficients of the CRC.
  1096.       <CRC lo>     = byte containing the 8 lo   order coefficients of the CRC.
  1097.  
  1098.  
  1099.       X/YMODEM Protocol Reference        09-11-86                       19
  1100.  
  1101.  
  1102.  
  1103.       7.1  CRC Calculation
  1104.  
  1105.       7.1.1  Formal_Definition
  1106.       To calculate the 16 bit   CRC the message bits are considered to be the
  1107.       coefficients of a polynomial. This message polynomial is first multiplied
  1108.       by X^16 and then divided by the generator polynomial (X^16 + X^12 + X^5 +
  1109.       1) using modulo two arithmetic. The remainder left after the division is
  1110.       the desired CRC. Since a message block in the Modem Protocol is 128 bytes
  1111.       or 1024 bits, the message polynomial will be of order X^1023.
  1112.       The hi order bit of the first byte of the message block is the
  1113.       coefficient of X^1023 in the message polynomial.  The lo order
  1114.       bit of the last byte of the message block is the coefficient of
  1115.       X^0 in the message polynomial.
  1116.  
  1117.           Figure 10.  Example of CRC Calculation written in C
  1118.       UPDCRC update routine from "rbsb.c".  Refer to the source code for these
  1119.       programs (contained in RZSZ1.SHQ and RZSZ2.SHQ) for usage.  A fast table
  1120.       driven macro is also included in this file.
  1121.       /* update CRC */
  1122.       unsigned short
  1123.       updcrc(c, crc)
  1124.       register c;
  1125.       register unsigned crc;
  1126.       {
  1127.         register count;
  1128.  
  1129.         for (count=8; --count>=0;) {
  1130.                 if (crc & 0x8000) {
  1131.                         crc <<= 1;
  1132.                         crc += (((c<<=1) & 0400)  !=  0);
  1133.                         crc ^= 0x1021;
  1134.                 }
  1135.                 else {
  1136.                         crc <<= 1;
  1137.                         crc += (((c<<=1) & 0400)  !=  0);
  1138.                 }
  1139.         }
  1140.         return crc;
  1141.       }
  1142.  
  1143.       7.2  CRC File Level Protocol Changes
  1144.  
  1145.       7.2.1  Common_to_Both_Sender_and_Receiver
  1146.       The only change to the File Level Protocol for the CRC option is the
  1147.       initial handshake which is used to determine if both the sending and the
  1148.       receiving programs support the CRC mode. All Modem Programs
  1149.       should support the checksum mode for compatibility with older
  1150.       versions.  A receiving program that wishes to receive in CRC
  1151.       mode implements the mode setting handshake by sending a <C> in
  1152.       place of the initial <nak>.  If the sending program supports CRC
  1153.       mode it will recognize the <C> and will set itself into CRC
  1154.       mode, and respond by sending the first block as if a <nak> had
  1155.       been received. If the sending program does not support CRC mode it will
  1156.  
  1157.  
  1158.       X/YMODEM Protocol Reference        09-11-86                       20
  1159.  
  1160.  
  1161.  
  1162.       not respond to the <C> at all. After the receiver has sent the
  1163.       <C> it will wait up to 3 seconds for the <soh> that starts the
  1164.       first block. If it receives a <soh> within 3 seconds it will
  1165.       assume the sender supports CRC mode and will proceed with the
  1166.       file exchange in CRC mode. If no <soh> is received within 3
  1167.       seconds the receiver will switch to checksum mode, send a <nak>,
  1168.       and proceed in checksum mode. If the receiver wishes to use
  1169.       checksum mode it should send an initial <nak> and the sending program
  1170.       should respond to the <nak> as defined in the original Modem Protocol.
  1171.       After the mode has been set by the initial <C> or <nak> the protocol
  1172.       follows the original Modem Protocol and is identical whether the checksum
  1173.       or CRC is being used.
  1174.  
  1175.  
  1176.       7.2.2  Receive_Program_Considerations
  1177.       There are at least 4 things that can go wrong with the mode setting
  1178.       handshake.
  1179.  
  1180.         1.  the initial <C> can be garbled or lost.
  1181.  
  1182.         2.  the initial <soh> can be garbled.
  1183.  
  1184.         3.  the initial <C> can be changed to a <nak>.
  1185.  
  1186.         4.  the initial <nak> from a receiver which wants to receive
  1187.             in checksum can be changed to a <C>.
  1188.  
  1189.       The first problem can be solved if the receiver sends a second <C> after
  1190.       it times out the first time. This process can be repeated several times.
  1191.       It must not be repeated too many times before sending a <nak> and
  1192.       switching to checksum mode or a sending program without CRC support may
  1193.       time out and abort. Repeating the <C> will also fix the second problem if
  1194.       the sending program cooperates by responding as if a <nak> were received
  1195.       instead of ignoring the extra <C>.
  1196.  
  1197.       It is possible to fix problems 3 and 4 but probably not worth the trouble
  1198.       since they will occur very infrequently. They could be fixed by switching
  1199.       modes in either the sending or the receiving program after a large number
  1200.       of successive <nak>s. This solution would risk other problems however.
  1201.  
  1202.  
  1203.       7.2.3  Sending_Program_Considerations
  1204.       The sending program should start in the checksum mode. This will insure
  1205.       compatibility with checksum only receiving programs. Anytime a <C> is
  1206.       received before the first <nak> or <ack> the sending program should set
  1207.       itself into CRC mode and respond as if a <nak> were received. The sender
  1208.       should respond to additional <C>s as if they were <nak>s until the first
  1209.       <ack> is received. This will assist the receiving program in determining
  1210.       the correct mode when the <soh> is lost or garbled. After the first <ack>
  1211.       is received the sending program should ignore <C>s.
  1212.  
  1213.  
  1214.       X/YMODEM Protocol Reference        09-11-86                       21
  1215.  
  1216.  
  1217.  
  1218.       7.3  Data Flow Examples with CRC Option
  1219.  
  1220.       Here is a data flow example for the case where the receiver requests
  1221.       transmission in the CRC mode but the sender does not support the CRC
  1222.       option. This example also includes various transmission errors.  <xx>
  1223.       represents the checksum byte.
  1224.  
  1225.             Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't
  1226.  
  1227.       SENDER                                          RECEIVER
  1228.                         <---                <C>
  1229.                                 times out after 3 seconds,
  1230.                         <---                <C>
  1231.                                 times out after 3 seconds,
  1232.                         <---                <C>
  1233.                                 times out after 3 seconds,
  1234.                         <---                <C>
  1235.                                 times out after 3 seconds,
  1236.                         <---                <nak>
  1237.       <soh> 01 FE -data- <xx>   --->
  1238.                         <---                <ack>
  1239.       <soh> 02 FD -data- <xx>   --->        (data gets line hit)
  1240.                         <---                <nak>
  1241.       <soh> 02 FD -data- <xx>   --->
  1242.                         <---                <ack>
  1243.       <soh> 03 FC -data- <xx>   --->
  1244.          (ack   gets garbaged)  <---                <ack>
  1245.                                 times out after 10 seconds,
  1246.                         <---                <nak>
  1247.       <soh> 03 FC -data- <xx>   --->
  1248.                         <---                <ack>
  1249.       <eot>                     --->
  1250.                         <---                <ack>
  1251.  
  1252.       Here is a data flow example for the case where the receiver requests
  1253.       transmission in the CRC mode and the sender supports the CRC
  1254.       option.  This example also includes various transmission errors.
  1255.       <xxxx> represents the  2 CRC bytes.
  1256.  
  1257.  
  1258.       X/YMODEM Protocol Reference        09-11-86                       22
  1259.  
  1260.  
  1261.  
  1262.           Figure 12.  Receiver and Sender Both have CRC Option
  1263.  
  1264.       SENDER                                         RECEIVER
  1265.                           <---                 <C>
  1266.       <soh> 01 FE -data- <xxxx> --->
  1267.                           <---                 <ack>
  1268.       <soh> 02 FD -data- <xxxx> --->           (data gets line hit)
  1269.                           <---                 <nak>
  1270.       <soh> 02 FD -data- <xxxx> --->
  1271.                           <---                 <ack>
  1272.       <soh> 03 FC -data- <xxxx> --->
  1273.       (ack gets garbaged)         <---                 <ack>
  1274.                                      times out after 10 seconds,
  1275.                           <---                 <nak>
  1276.       <soh> 03 FC -data- <xxxx> --->
  1277.                           <---                 <ack>
  1278.       <eot>                       --->
  1279.                           <---                 <ack>
  1280.  
  1281.  
  1282.       8.  MORE INFORMATION
  1283.  
  1284.       More information may be obtained by calling Telegodzilla at 503-621-3746.
  1285.       Hit RETURNs for baud rate detection.Speed detection is automatic for 300,
  1286.       1200, and 2400 bps.
  1287.  
  1288.       A version this file with boldface, underlining, and superscripts for
  1289.       printing on Epson or Gemini printers is available on Telegodzilla as
  1290.       "YMODEME.DOC" or "YMODEME.DQC".
  1291.  
  1292.       UUCP sites can obtain this file   with
  1293.              uucp omen!/usr/spool/uucppublic/ymodem.doc /tmp
  1294.       A continually updated list of available   files is stored in
  1295.       /usr/spool/uucppublic/FILES.
  1296.  
  1297.       The following L.sys line calls Telegodzilla (Pro-YAM in host operation).
  1298.       Telegodzilla waits for carriage returns to determine the incoming speed.
  1299.       If none is detected, 1200 bps is assumed and a greeting is displayed.
  1300.  
  1301.       In response to "Name Please:" uucico gives the Pro-YAM "link"
  1302.       command as a user name.  The password (Giznoid) controls access
  1303.       to the Xenix system connected to the IBM PC's other serial port.
  1304.       Communications between Pro-YAM and Xenix use 9600 bps; YAM
  1305.       converts this to the caller's speed.
  1306.  
  1307.       Finally, the calling uucico logs in as uucp.
  1308.  
  1309.       omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
  1310.  
  1311.       Contact omen!caf if you wish the troff source files.
  1312.  
  1313.  
  1314.       X/YMODEM Protocol Reference        09-11-86                       23
  1315.  
  1316.  
  1317.  
  1318.       9.  Document Revisions
  1319.  
  1320.       The September 11 1986 edition clarifies nomenclature and some minor
  1321.       points.  The April 15 1986 edition clarifies some points concerning CRC
  1322.       calculations and spaces in the header.
  1323.  
  1324.  
  1325.       10.  YMODEM Programs
  1326.  
  1327.       A demonstration version of Professional-YAM is available as ZMODEM.ARC
  1328.       This may be used to test YMODEM amd ZMODEM implementations.
  1329.  
  1330.       Unix programs supporting the YMODEM protocol are available on
  1331.       Telegodzilla as RZSZ1.SHQ and RZSZ2.SHQ (SQueezed shell archives).
  1332.       Most Unix like systems are supported, including V7, Xenix, Sys III,
  1333.       4.2 BSD, SYS V, Idris, Coherent, and Regulus.
  1334.  
  1335.       A version for VAX-VMS is available in VRBSB.SHQ.
  1336.  
  1337.       Irv Hoff has added YMODEM 1k packets and basic YMODEM batch transfers to
  1338.       the KMD and IMP series programs, which replace the XMODEM and
  1339.       MODEM7/MDM7xx series respectively.  Overlays are available for a wide
  1340.       variety of CP/M systems.
  1341.  
  1342.       Questions about YMODEM, the Professional-YAM communications program, and
  1343.       requests for evaluation copies may be directed to:
  1344.            Chuck Forsberg
  1345.            Omen Technology Inc
  1346.            17505-V Sauvie Island Road
  1347.            Portland Oregon 97231
  1348.            Voice: 503-621-3406
  1349.            Modem: 503-621-3746 Speed: 2400,1200,300
  1350.            Usenet: ...!tektronix!reed!omen!caf
  1351.            Compuserve: 70007,2304
  1352.            Source: TCE022
  1353.